<?php
declare(strict_types=1);

use Zlf\AppValidate\Type;
use Zlf\AppValidate\ValidateAbstract;

include "../vendor/autoload.php";

class Validate extends ValidateAbstract
{
    public function rules(): array
    {
        return [
            [
                'type',
                Type::VIOLATE,
                'words' => ['Sub', '三李四', '高代码'],
                'model' => 'warn'
            ]
        ];
    }

    public function labels(): array
    {
        return [
            'type' => '标题',
        ];
    }
}

$validate = new Validate();
$validate->setData([
    'type' => [
        'name' => '1张三李四王五',
        'sex' => '2这种方法不仅有助Sub于提高代码的可读性和可维护性',
        'info' => [
            '3张三李四王五',
            '4这种方法不仅有助Sub于提高代码的可读性和可维护性',
        ],
        'more' =>
            [
                'a' => '5张三李四王五',
                'b' => '6这种方法不仅有助Sub于提高代码的可读性和可维护性',
                'more' =>
                    [
                        'a' => '7张三李四王五',
                        'b' => '8这种方法不仅有助Sub于提高代码的可读性和可维护性',
                    ]
            ]
    ]
]);
$validate->validate();
if ($validate->isFail()) {//验证失败
    print_r($validate->getErrorList());
} else {//验证成功
    print_r($validate->getSafeData());
}